<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	template="/WEB-INF/templates/template.xhtml">

	<ui:define name="menu">
		<ui:include src="/protected/admin/menu.xhtml">
			<ui:param name="activeMenu" value="users" />
			<ui:param name="activeSubMenu" value="search" />
		</ui:include>
	</ui:define>
	<ui:define name="breadcrumb">
		<ui:include src="breadcrumbIndex.xhtml" />
	</ui:define>
	<ui:define name="content">
		<h:form id="form-search" styleClass="well form-search">
			<label>Nombre de Usuario:</label>
			<h:inputText id="buscarNombre" styleClass="input-xlarge search-query"
				value="#{userBean.input.text}">
			</h:inputText>
			<h:commandButton action="#{userBean.search}"
				value="#{messages.search}" styleClass="btn" />
		</h:form>
		<h:form id="form-content">
			<rich:dataTable styleClass="table table-bordered table-striped"
				value="#{userBean.dataModel}" 
				id="resultTable" var="result" rows="10">

				<rich:column>
					<f:facet name="header"></f:facet>
					<h:selectBooleanCheckbox value="#{result.selected}" />
				</rich:column>

				<rich:column>
					<f:facet name="header">
						<h:outputText value="#{messages.usersUsername}" />
					</f:facet>
					<h:link outcome="edit">
						<h:outputText value="#{result.entity.username}" />
						<f:param name="username" value="#{result.entity.username}" />
					</h:link>
				</rich:column>

				<rich:column>
					<f:facet name="header">
						<h:outputText value="#{messages.loginEnabled}" />
					</f:facet>
					<h:outputText value="#{messages[result.entity.enabled]}" />
				</rich:column>
				
				<rich:column>
					<f:facet name="header">
						<h:outputText value="#{messages.actiones}" />
					</f:facet>
					<h:commandLink action="#{editUserBean.showEdit}">
						<i class="icon-edit" title="#{messages.edit}"></i>
						<f:setPropertyActionListener value="#{result.entity.username}"
							target="#{editUserBean.username}" />
						<f:setPropertyActionListener value="#{facesContext.viewRoot.viewId}"
							target="#{editUserBean.persistReturnView}" />
						<f:setPropertyActionListener value="#{facesContext.viewRoot.viewId}"
							target="#{editUserBean.cancelView}" />
					</h:commandLink>

					<h:commandLink action="#{userBean.showRemove}">
						<i class="icon-remove" title="#{messages.remove}"></i>
						<f:setPropertyActionListener value="#{result}"
							target="#{userBean.entity}" />
						<f:setPropertyActionListener value="#{facesContext.viewRoot.viewId}"
							target="#{userBean.persistReturnView}" />
						<f:setPropertyActionListener value="#{facesContext.viewRoot.viewId}"
							target="#{userBean.cancelView}" />
					</h:commandLink>
				</rich:column>
 			</rich:dataTable>
 		</h:form>
	</ui:define>
</ui:composition>
